Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some explicit integer64 support #204

Merged
merged 5 commits into from
Oct 23, 2024
Merged

Add some explicit integer64 support #204

merged 5 commits into from
Oct 23, 2024

Conversation

hadley
Copy link
Member

@hadley hadley commented Oct 21, 2024

Fixes #159

@MichaelChirico does this make sense to you?

R/num_equal.R Outdated
attributes(x) <- NULL
attributes(y) <- NULL
if (is_int64(x) || is_int64(y)) {
x <- bit64::as.integer64(x)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one concern here is trying to compare numbers from the nonoverlapping domains of int64 and double (forget the exact values off the top of my head)

i.e. an integer without exact representation as double vs a double too large for integer64

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh yeah, good thought. 36893488147419103232 is an integer (2^65) that's you can represent with a double, but not in int64. But of course not all integers bigger than that can be represented, e.g. 36893488147419103232 + 1 == 36893488147419103232 is TRUE.

Copy link
Contributor

@MichaelChirico MichaelChirico Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That too! I also had in mind the converse, integers near 2^60 that can be represented in int64 but not in double, for example any integer between 0x43B0000000000000 == 1152921504606846976 and 0x43B0000000000001==1152921504606847232 (ref / wiki)

@hadley hadley merged commit 9e1d773 into main Oct 23, 2024
13 checks passed
@hadley hadley deleted the bit64 branch October 23, 2024 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better comparison for bit64 and numeric
2 participants